import { baseUrl } from './config.js';

export function topList() {
	return uni.request({
		url: `${baseUrl}/toplist/detail`,
		method: "GET"
	}).then(res => {
		return res.data; // 直接返回 res.data，而不是 res.data.list.slice(0, 4)
	});
}

export function listDetail(listid) {
    return uni.request({
        url: `${baseUrl}/playlist/detail?id=${listid}`,
        method: "GET"
    }).then(res => {
        return res.data;
    });
}

// export function listDetail(listId)
// {
// 	return uni.request({
// 		url:`${baseUrl}/playlist/detail?id=${listId}`,
// 		method:'GET'
// 	})
// }

export function songDetail(id){
	return uni.request({
		url:`${baseUrl}/song/detail`,
		method:'GET',
		data:{
					ids:id
				}
	}).then(res=>{
	return res.data;
	})
}

export function songUrl(id){
	return uni.request({
		url:`${baseUrl}/song/url`,
		method:'GET',
		data:{
					id:id
				}
	}).then(res=>{
	return res.data;
	})
}
export function lyric(id){
	return uni.request({
		url:`${baseUrl}/lyric`,
		method:'GET',
		data:{
					id:id
				}
	}).then(res=>{
	return res.data;
	})
}
export function searchHot(){
	return uni.request({
		url : `${baseUrl}/search/hot/detail`,
		method : 'GET'
	}).then(res=>{
		return res.data
	})
}

export function searchWord(word){
	return uni.request({
		url : `${baseUrl}/search?keywords=${word}`,
		method : 'GET',
		data:{
			word: word
		}
	}).then(res=>{
		return res.data
	})
}

export function searchSuggest(word){
	return uni.request({
		url : `${baseUrl}/search/suggest?keywords=${word}&type=mobile`,
		method : 'GET',
		data:{
			word:word
		}
	}).then(res=>{
		return res.data
	})	
	
	
}

